export default {
	namespaced:true,
	//state的数据
	state:()=>({
		//收货地	
		address:JSON.parse(uni.getStorageSync("address") || "{}"),
		token:JSON.parse(uni.getStorageSync("token") || '""'),
		userInfo:JSON.parse(uni.getStorageSync("userInfo") || "{}"),
		//存储跳转的路径和方式
		rederictInfo:{}
	}),
	mutations:{
		updateAddress(state,address){
				state.address = address;
				console.log("state值是",state.address);
				//通过this.commit("模块名/方法名") 调用方法 储存到本地
				this.commit("m_user/saveAddress");
				console.log(this);
		},
		saveAddress(state){
			uni.setStorageSync("address",JSON.stringify(state.address));
		}
		,
		saveuserInfo(state){
			uni.setStorageSync("userInfo",JSON.stringify(state.userInfo));
		},
		//修改用户信息
		updateuserInfo(state,UserInfo){
			state.userInfo = UserInfo;
			this.commit("m_user/saveuserInfo");
		},
		updateToken(state,token){
			state.token = token;
			this.commit("m_user/saveToken");
		},
		saveToken(state){
			uni.setStorageSync("token",JSON.stringify(state.token));
		},
		//更改何从定向的信息
		updateRederictInfo(state,newInfo){
			state.rederictInfo = newInfo;
		}
	},
	//mutations 方法
	getters:{
		details(state){
			return state.address.provinceName + state.address.cityName +state.address.countyName+state.address.detailInfo;
		},
	}
}